import iconAudio from '@/assets/image/ext/audio.png'
import icon7z from '@/assets/image/ext/7z.png'
import iconGz from '@/assets/image/ext/gz.png'
import iconIso from '@/assets/image/ext/iso.png'
import iconRar from '@/assets/image/ext/rar.png'
import iconTar from '@/assets/image/ext/tar.png'
import iconZip from '@/assets/image/ext/zip.png'
import iconCsv from '@/assets/image/ext/csv.png'
import iconDoc from '@/assets/image/ext/doc.png'
import iconDocx from '@/assets/image/ext/docx.png'
import iconHtml from '@/assets/image/ext/html.png'
import iconMd from '@/assets/image/ext/md.png'
import iconPdf from '@/assets/image/ext/pdf.png'
import iconPpt from '@/assets/image/ext/ppt.png'
import iconPptx from '@/assets/image/ext/pptx.png'
import iconTxt from '@/assets/image/ext/txt.png'
import iconXls from '@/assets/image/ext/xls.png'
import iconXlsx from '@/assets/image/ext/xlsx.png'

const SuffixMap: Record<string, string> = {
    csv: iconCsv,
    doc: iconDoc,
    docx: iconDocx,
    html: iconHtml,
    md: iconMd,
    pdf: iconPdf,
    ppt: iconPpt,
    pptx: iconPptx,
    xls: iconXls,
    xlsx: iconXlsx,
    txt: iconTxt,
    '7z': icon7z,
    iso: iconIso,
    rar: iconRar,
    tar: iconTar,
    zip: iconZip,
    gz: iconGz,
    mp3: iconAudio
}

const suffixUtil = {
    findUnitIcon(name: string) {
        const suffix: string | undefined = name.split('.').pop()
        for (const nameKey in SuffixMap) {
            if (suffix?.includes(nameKey)) {
                return SuffixMap[nameKey]
            }
        }
        return SuffixMap.folder
    }
}

export default suffixUtil
